package com.cj.pj.sys.controller;

import com.cj.pj.sys.common.annotation.AddLogs;
import com.cj.pj.sys.common.pojo.JsonResult;
import com.cj.pj.sys.pojo.SysRole;
import com.cj.pj.sys.service.SysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class SysRoleController {
    @Autowired
    SysRoleService sysRoleService;

    @RequestMapping("/role/doFindRoles")
    public JsonResult doFindRoles(){
        return new JsonResult(sysRoleService.findRoles());
    }

    @RequestMapping("/role/doFindPageObjects")
    public JsonResult doFindPageObjects(String name,Integer pageCurrent){
        return new JsonResult(sysRoleService.findPageObject(name,pageCurrent));
    }


    @RequestMapping("/role/doSaveObject")
    public JsonResult doSaveObject(SysRole sysRole,int... menuIds){
        return new JsonResult( sysRoleService.addSysRole(sysRole,menuIds));
    }

    @RequestMapping("/role/doFindObjectById")
    public JsonResult doFindObjectById(int id){
        return new JsonResult(sysRoleService.findObjectById(id));
    }


    @RequestMapping("/role/doUpdateObject")
    public JsonResult doUpdateObject(SysRole sysRole,int...menuIds){
        return new JsonResult(sysRoleService.updateRole(sysRole,menuIds));
    }

    @RequestMapping("/role/doDeleteObject")
    public JsonResult doDeleteObject(int id){

        return  new JsonResult(sysRoleService.deleteObjectById(id));
    }
}
